package com.dragon.permission_service.util;

import com.dragon.permission_service.Exception.StateCode;
import com.dragon.permission_service.common.BaseResponse;

public class ResultUtils<T> {
    public static <T>BaseResponse<T> error(StateCode errorCode, String errorMsg) {
        return error(errorCode.getCode(),errorMsg);
    }
    public static <T>BaseResponse<T> error(StateCode errorCode) {
        return error(errorCode.getCode(),errorCode.getMessage());

    }
    public static <T>BaseResponse<T> error(Integer code,String message) {
        return new BaseResponse<>(null,code,message);
    }
    public static <T>BaseResponse<T> success(T data, StateCode successCode,String message) {

        return new BaseResponse<>(data,successCode.getCode(),message);
    }
    public static <T>BaseResponse<T> success(T data, StateCode successCode) {
        return success(data,successCode, successCode.getMessage());
    }
    public static <T>BaseResponse<T> success(T data) {
        return new BaseResponse<>(data,200,"ok");
    }
}
